package com.crane.common.framework.shiro;

import org.aopalliance.intercept.MethodInvocation;
import org.apache.shiro.spring.security.interceptor.AopAllianceAnnotationsAuthorizingMethodInterceptor;

public class ShiroSwitchInterceptor extends AopAllianceAnnotationsAuthorizingMethodInterceptor {

    private boolean flag = false;

    @Override
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        org.apache.shiro.aop.MethodInvocation mi = createMethodInvocation(methodInvocation);
        if (flag) {
            return mi.proceed();
        } else {
            return super.invoke(mi);
        }

    }

    public boolean isFlag() {
        return flag;
    }

    public void setFlag(boolean flag) {
        this.flag = flag;
    }
}
